<?php
include 'config.php';
ini_set('date.timezone','Asia/Shanghai');//调整时区
$hdid1=$config['hdid1'];//活动名称
$hdid2=$config['hdid2'];//活动名称
$time=$config['time'];//时间

$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "data";
ini_set('date.timezone','Asia/Shanghai');
$conn = new mysqli($servername, $username, $password, $dbname);
// 检测连接
if ($conn->connect_error) {
    die("连接失败: " . $conn->connect_error);
}
$date[]=array();
$sql="select * , SUBSTRING(  `date` , 1, 15 ) AS dateindex from msg WHERE  (hdid='$hdid1'or hdid ='$hdid2') and SUBSTRING(  `date` , 1, 10 )='$time' order by date asc limit 1";
$result=$conn->query($sql);
$temp= $result->fetch_assoc();
$start=$temp['dateindex'].'0';
//echo $start;
$sql="select * , SUBSTRING(  `date` , 1, 15 ) AS dateindex from msg WHERE  (hdid='$hdid1'or hdid ='$hdid2') and SUBSTRING(  `date` , 1, 10 )='$time' order by date desc limit 1";
$result=$conn->query($sql);
$temp= $result->fetch_assoc();
$end=$temp['dateindex'].'0';
//echo $end;
$f=floor((strtotime($end)-strtotime($start))%86400/600);
$now=strtotime($start);
for($i=0;$i<$f;$i++) {
    $date[] = date('H:i',$now);
    $now = $now + 10 * 60;
  //  print_r($now.'<br/>');
}
echo json_encode($date);
$conn->close();

?>